import { Injectable } from '@nestjs/common';
import { InjectEntityManager, InjectRepository } from '@nestjs/typeorm';
import { EntityManager, In, Like, Repository } from 'typeorm';
import { UserEntity } from '../../modules/user/user.entity';
import { BusinessException } from '~/common/exceptions/biz.exception';
import { ErrorEnum } from '~/constants/error-code.constant';
import { isEmpty, isNil } from 'lodash';

@Injectable()
export class DataBaseLinkService {
  constructor(
    @InjectRepository(UserEntity)
    private readonly userRepository: Repository<UserEntity>
  ) {}

  //根据人员id查询人员信息
  async getUserById(userId: any) {
    const user = await this.userRepository.findOneBy({ id: userId });
    if (isEmpty(user)) throw new BusinessException(ErrorEnum.USER_NOT_FOUND);
    return user;
  }
}
